"""
子类重用父类的功能
在子类派生出新方法中重用父类功能的方式一：
指名道姓地引用某一个类中的函数
"""
"""class People:
    school = "不造啊"
    def __init__(self,name,age,sex):
        self.name = name
        self.age = age
        self.sex = sex
class Student(): # 没有继承People父类
    def __init__(self,name,age,sex,score =0 ):
        People.__init__(self,name,age,sex)
        self.score = score
    def play(self):
        print("%s play football" %self.name)
class Teacher():
    def __init__(self,name,age,sex,hobby):
        People.__init__(self,name,age,sex)
        self.hobby = hobby
    def course(self):
        print("%s course" % self.name)"""
# 根据student类创建的对象
"""stu1 = Student("小龙",19,"男",100)
stu1.play()"""
# 根据Teacher类创建的对象
"""tea1 = Teacher("小白",19,"男",'篮球')
tea1.course()"""

# 子类派生的新方法中重用父类功能的方式二
class People:
    school = "不造呀"
    def __init__(self,name,age,sex):
        self.name = name
        self.age = age
        self.sex = sex
class Student(People):
    def __init__(self,name,age,sex,score=0):
        super(Student,self).__init__(name,age,sex)
        self.score = score
    def play(self):
        print("%s play football" %self.name)
class Teacher(People):
    def __init__(self,name,age,sex,hobby):
        super().__init__(name,age,sex)
        self.hobby = hobby
    def course(self):
        print("%s course"%self.name)

stu1 = Student("小龙",30,'男',100)
print(stu1.__dict__) # {'name': '小龙', 'age': 30, 'sex': '男', 'score': 100}






